#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QScreen>
#include <QLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // 去除边框
    //setWindowFlags(Qt::FramelessWindowHint);

    // 清除布局边距
    // if (centralWidget() && centralWidget()->layout()) {
    //     centralWidget()->layout()->setContentsMargins(0, 0, 0, 0);
    // }

    // 获取所有屏幕
    QList<QScreen *> screens = QGuiApplication::screens();
    if (screens.size() < 2) {
        qWarning() << "Only 1 screen detected!";
        showMaximized(); // 单屏则最大化
        return;
    }

    // 计算两个屏幕的联合区域
    QRect combinedGeometry;
    for (QScreen *screen : screens) {
        combinedGeometry = combinedGeometry.united(screen->geometry());
    }

    // 设置窗口跨屏全屏
    setGeometry(combinedGeometry);
    show(); // 必须调用 show() 或 showFullScreen()
}

MainWindow::~MainWindow()
{
    delete ui;
}
